/*  This file is part of -_-.

    -_- is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    -_- is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with -_-.  If not, see <http://www.gnu.org/licenses/>.

    Copyright 2012-2013 Oliver Katz */

#ifndef __COMMON_TYPES_ASSOC_H
#define __COMMON_TYPES_ASSOC_H

#include "../data.h"
#include "string.h"

#define Z_WARNING_ASSOC(a, r) Z_WARNING_DATA((&(a)->content), r)

typedef struct _z_assoc
{
    z_data content;
    struct _z_assoc *branches[256];
} _z_assoc;

z_data z_assoc_new(); //method: create new associative array
z_data *_z_assoc_new();
int z_assoc_del(z_data *a); //method: delete associative array
z_data *z_assoc_at(z_data *a, z_data *s); //method: get reference to the z_data content from a name

/// This is an associative array (like a map<string, z_data> in c++). Here's an example of how to use one:
///
/// {{z_data assoc = z_assoc_new();
/// char *key = "thisIsAKey";
/// *z_assoc_at(&assoc, z_data_wrap(key, strlen(key)*sizeof(char))) = z_data_init(0, 0);
/// z_assoc_del(&assoc);}}

#endif
